﻿using Lufei_CaterDAL;
using Lufei_CaterModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lufei_CaterBLL
{
    public class ProductBLL
    {


        ProductDAL dal=new ProductDAL();

        /// <summary>
        /// 获取所有商品信息
        /// </summary>
        /// <returns></returns>
        public List<ProductInfo> GetProducts()
        {
            return dal.GetProducts();
        }

        /// <summary>
        /// 根据id获取商品
        /// </summary>
        /// <returns></returns>
        public List<ProductInfo> GetProductInfoByID(int id)
        {
            return dal.GetProductInfoByID(id);
        }


        /// <summary>
        /// 拼音数字检索
        /// </summary>
        /// <param name="str">拼音</param>
        /// <param name="temp">数字标记位 1---拼音 2---数字</param>
        /// <returns></returns>
        public List<ProductInfo> GetProductInfoBySpellOrNum(string str, int temp)
        {
            return dal.GetProductInfoBySpellOrNum(str, temp);
        }

        /// <summary>
        /// 根据id获取一个商品
        /// </summary>
        /// <returns></returns>
        public ProductInfo GetProductInfoOneByID(int id)
        {
            return dal.GetProductInfoOneByID(id);
        }

        /// <summary>
        /// 插入商品数据
        /// </summary>
        /// <param name="pi"></param>
        /// <returns></returns>
        public bool InsertProduct(ProductInfo pi)
        {
            return dal.InsertProduct(pi) > 0;
        }

        /// <summary>
        /// 修改商品
        /// </summary>
        /// <returns></returns>
        public bool UpdateProduct(ProductInfo pi)
        {
            return dal.UpdateProduct(pi)>0;
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool ProductDelectById(int id)
        {
            return dal.ProductDelectById(id)>0;
        }

    }
}
